﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Annual_faculty_promotions.WebUI.Helpers.Filters;
using Annual_faculty_promotions.WebUI.Models;

namespace Annual_faculty_promotions.WebUI.Areas.UserArea.Controllers
{
    // kalij khale khi hasi
    public class DashboardController : Controller
    {
        //
        // GET: /UserArea/Dashboard/
        public ActionResult Index()
        {
            return View();
        }


    
        public ActionResult Cartable()
        { return View();}

    [AjaxOnly]
        public ActionResult GetNavData()
        {
            List<TreeNode> nodes = new List<TreeNode>()
                {
                    new TreeNode()
                    {
                        Text = "تعاریف_اولیه",
                        IconCls = "pic_26",
                        Children = new List<TreeNode>()
                        {
                            new TreeNode() { Text = "ساختار دانشگاه", IconCls = "pic_264", Url = Url.Action("Index", "UnivercityStructure") },                                           
                            new TreeNode() { Text = "نقش ها", IconCls = "pic_72", Url = Url.Action("Index", "RolesAdmin") },                            
                        }
                    },
                     new TreeNode()
                    {
                        Text = "داشبورد",
                        IconCls = "pic_26",
                        Children = new List<TreeNode>()
                        {
                            new TreeNode() { Text = "ثبت درخواست", IconCls = "pic_204", Url = Url.Action("Index", "UnivercityStructure") },                                           
                            new TreeNode() { Text = "نقش ها", IconCls = "pic_72", Url = Url.Action("Index", "RolesAdmin") },                            
                        }
                    },
                        new TreeNode()
                    {
                        Text = "مدیریت،کاربران",
                        IconCls = "pic_26",
                        Children = new List<TreeNode>()
                        {
                            new TreeNode() { Text = "تعیین نقش", IconCls = "pic_264", Url = Url.Action("Index", "UserAdmin") },              
                            new TreeNode() { Text = "تعریف کاربر", IconCls = "pic_263", Url = Url.Action("Index", "UserAdmin") },
                             new TreeNode() { Text = "سطح دسترسی", IconCls = "pic_265", Url = Url.Action("Index", "UserAdmin") }
                        }
                    }
                };

            Action<ICollection<TreeNode>> action = list =>
            {
                foreach (var node in list)
                {
                    node.Id = "node" + node.Text;
                }
            };

            foreach (var node in nodes)
            {
                node.Id = "node" + node.Text;
                if (node.Children != null && node.Children.Count > 0)
                {
                    action(node.Children);
                }
            }

            return Json(nodes, JsonRequestBehavior.AllowGet);
        }
    }
}